<template>
  <div>
    <!-- 侧边栏导航 -->
    
    <el-menu
      :default-active="defaultActive"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      unique-opened
      router
    >
      <el-menu-item index="/home">
        <i class="el-icon-platform-eleme"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu v-for="item in $store.getters.getUser.menus" :key="item.id" :index="item.id.toString()">
        <template slot="title">
          <i :class="item.icon"></i>
          <span>{{ item.title }}</span>
          <!-- <el-menu-item index="1-3">管理员管理</el-menu-item> -->
        </template>
        <el-menu-item v-for="menu in item.children" :key="menu.id" :index="menu.url">{{ menu.title }}</el-menu-item>
        <!-- <el-menu-item index="/sps">商品规格</el-menu-item> -->
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      defaultActive:'/home'
    };
  },
  mounted(){
    //当用户刷新的时候 重新给默认选中赋值
    this.defaultActive = this.$route.path
    // console.log(this.$store.getters.getUser.menus);
  }
};
</script>

<style scoped>
.el-menu {
  min-height: 600px;
}
</style>
